﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="VoucherFormat.aspx.cs" Culture="en-GB" Inherits="Main_Accounts_VoucherFormat" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControl" %>
<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
   <title>Voucher Format</title>
        <link href="../../Styles/accounts.css" rel="Stylesheet" type="text/css" />    
        <script src="../../JavaScript/ModalPopups.js" type="text/javascript"></script>
        <script language="javascript" type="text/javascript">        
            function isNumberKey(control_id, evt) {
                var charCode = (evt.which) ? evt.which : event.keyCode
                if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 45 || charCode > 47))
                    return false;

                if (charCode == 46) {
                    var dotcount = document.getElementById(control_id).value.split('.').length - 1;
                    if (dotcount >= 1) {
                        return false;
                    }
                }
                return true;
            }
            
            function checkJournal()
            {
                var e = document.getElementById("ddlParentVoucher");
                var RadioList = document.getElementById("radioStandard");
                var strUser = e.options[e.selectedIndex].value;
                if(strUser=='4')
                { 
                    RadioList.style.visibility="visible";
                }
                else
                {
                    RadioList.style.visibility="hidden";
                } 
            }
            function AutoNumber()
            {
                var resetNo = document.getElementById("chkNewNumber");
                if(chkAutoNumber.checked==false)
                {
                    txtStartNumber.value='';
                    txtStartNumber.style.backgroundColor="#d4d0c8";  
                    resetNo.checked=false;
                    resetNo.disabled=true;                  
                    txtStartNumber.disabled=true;                      
                }
                else
                {
                    txtStartNumber.disabled=false;
                    txtStartNumber.style.backgroundColor="#ffffff"; 
                    txtStartNumber.value='1';
                    resetNo.disabled=false;                
                }            
            }
            function CommonNarration()
            {
                var txtCommonNarration = document.getElementById("txtCommonNarration");
                var chkCommonNarration = document.getElementById("chkCommonNarration");
                if(chkCommonNarration.checked==false)
                {
                    txtCommonNarration.value='';
                    txtCommonNarration.style.backgroundColor="#d4d0c8";
                    txtCommonNarration.disabled=true;                      
                }
                else
                {
                    txtCommonNarration.disabled=false;
                    txtCommonNarration.style.backgroundColor="#ffffff"; 
                }            
            }
            
       function ModalPopupsWait() 
       {  
            ModalPopups.Indicator("idIndicator2",  
            "Please wait",  
            "<div style=''>" +  
            "<div style='float:left;'><img src='../../Images/spinner.gif'></div>" +   
            "<div style='float:left; padding-left:10px;'>" +   
            "Saving User Information... <br/>" +   
            "This may take few seconds." +   
            "</div>",   
            {  
               width: 300,  
              height: 100  
            }  
            );   
            setTimeout('ModalPopups.Close(\"idIndicator2\");', 3000);  
        } 
          
        
        function ModalPopupsAlert()
        {  
           ModalPopups.Alert("jsAlert1",  
           document.getElementById("hidHeading").value,  
           "<div style='padding-left:10px; width:150px;'>"+document.getElementById("hidMessage").value+"</div>",             
           {  
             okButtonText: "OK"  
           }  
           );  
        }
        function AlertMessage(msg)
        {  
           ModalPopups.Alert("jsAlert1",  
           "Required:",  
           "<div style='padding:25px 5px 25px 10px; width:160px;'>"+msg+"</div>",             
           {  
             okButtonText: "OK"  
           }  
           );  
        }
        function RequiredField()
        {   
            if(document.getElementById("txtVoucherName").value=='')
            {
                AlertMessage('Specify Voucher Name'); 
                document.getElementById("txtVoucherName").focus();
                 return false; 
            }
            else if(document.getElementById("ddlParentVoucher").selectedIndex==0)
            {
                AlertMessage('Specify Parent Voucher Types'); 
                document.getElementById("ddlParentVoucher").focus();              
                return false;               
            }
            
        }
          </script>
            
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
        <div class="divmain">
            <acc:heading ID="header1" runat="server" HeadingText="Voucher Format" />               
        </div>
         <asp:Panel ID="PnlAddNew" runat="server" Visible="false">
        <div style="width:80%; margin-left:10%; margin-right:10%" class="tablecontent">
            <table style="width:100%; margin-bottom:10px">
                <tr>
                    <td colspan="4" class="headtd">
                        Voucher Details                    
                    </td>
                </tr>
                 <tr>
                    <td style="width:25%">
                        Voucher Name<span class="required">*</span>                    
                    </td>
                    <td style="width:30%">
                        <asp:TextBox ID="txtVoucherName" runat="server" CssClass="input"></asp:TextBox>                   
                    </td>
                    <td>
                        Abbreviation                    
                    </td>
                    <td>
                        <asp:TextBox ID="txtAbbreviation" runat="server" CssClass="input"></asp:TextBox>                       
                    </td>
                </tr>
                <tr>
                    <td>
                        Parent Voucher Type<span class="required">*</span>                    
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlParentVoucher" runat="server" CssClass="dropdown" onchange="checkJournal();" Width="145px"></asp:DropDownList>                  
                    </td>
                    <td colspan="2">
                        <asp:RadioButtonList ID="radioStandard" runat="server" RepeatDirection="Horizontal" style="visibility:hidden;">
                            <asp:ListItem Text="Standard" Value="0"></asp:ListItem>
                            <asp:ListItem Text="TDS" Value="2"></asp:ListItem>
                        </asp:RadioButtonList>                
                    </td>
                </tr>
                 <tr>
                    <td>
                        Effective Date                  
                    </td>
                    <td>
                        <asp:TextBox ID="txtEffectiveDate" runat="server" CssClass="input" ValidationGroup="V" ></asp:TextBox>
                        <asp:ImageButton ID="btnDate" runat="server" ImageUrl="~/Images/calendar.gif" />
                        <AjaxControl:CalendarExtender ID="cal" runat="server" PopupButtonID="btnDate" TargetControlID="txtEffectiveDate" Format="dd/MM/yyyy"></AjaxControl:CalendarExtender>
                        <AjaxControl:MaskedEditExtender ID="maskExt" runat="server" MaskType="Date" Mask="99/99/9999" TargetControlID="txtEffectiveDate"></AjaxControl:MaskedEditExtender>
                        <AjaxControl:MaskedEditValidator ID="maskValid" runat="server" ControlExtender="maskExt" InvalidValueMessage="Invalid Date" IsValidEmpty="true" Display="Dynamic" ValidationGroup="V" ControlToValidate="txtEffectiveDate"></AjaxControl:MaskedEditValidator>                                                        
                        
                    </td>
                    <td colspan="2">
                       &nbsp;             
                    </td>
                </tr>
            </table>
            <table style="width:100%; margin-bottom:10px">
                <tr>
                    <td colspan="3" class="headtd" style="border-top:1px solid #818181;">
                        Voucher Settings                   
                    </td>
                </tr>
                 <tr>
                    <td style="width:25%">
                        Starting Number
                    </td>
                    <td style="width:25%">
                        <asp:TextBox ID="txtStartNumber" runat="server" CssClass="inputnumber" Text="1" onkeypress="return isNumberKey(this.id,event)"></asp:TextBox>                   
                    </td>
                    <td>
                        <asp:CheckBox ID="chkAutoNumber" runat="server" Checked="true" Text="Auto Numbering" onclick="return AutoNumber();" />                   
                    </td>                    
                </tr>
                <tr>
                    <td>
                        Prefix
                    </td>
                    <td>
                        <asp:TextBox ID="txtPrefix" runat="server" CssClass="input"></asp:TextBox>                   
                    </td>
                    <td>
                        <asp:CheckBox ID="chkPrintAfterSave" runat="server" Text="Print After Save" />                   
                    </td>                    
                </tr>
                <tr>
                    <td>
                        Suffix
                    </td>
                    <td>
                        <asp:TextBox ID="txtSuffix" runat="server" CssClass="input"></asp:TextBox>                   
                    </td>
                    <td>
                        <asp:CheckBox ID="chkNewNumber" runat="server" Text="New No. Each Year" />                   
                    </td>                    
                </tr>
                 <tr>
                    <td valign="top">
                        <asp:CheckBox ID="chkCommonNarration" runat="server" Text="Common Narration" onclick="return CommonNarration();" />
                    </td>
                    <td valign="top">
                        <asp:TextBox ID="txtCommonNarration" runat="server" CssClass="input" Width="144px" TextMode="MultiLine" Height="40px" Enabled="false" BackColor="#d4d0c8"></asp:TextBox>                   
                    </td>
                    <td valign="top">
                        <asp:CheckBox ID="chkEachNarration" runat="server" Text="Each A/c Narration" /><br />  
                        <asp:CheckBox ID="chkApplyReference" runat="server" Text="Apply Reference" />                 
                    </td>                    
                </tr>
                
            </table>
        </div>
        <div style="width:60%; margin-left:20%; margin-right:20%; margin-top:10px; text-align:center">
            <asp:Button ID="btnSubmit" runat="server" Text="Submit" CssClass="button" OnClientClick="return RequiredField();" OnClick="btnSubmit_Click" /> &nbsp;
            <asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="button" onclick="btnCancel_Click" />
        </div>
        </asp:Panel>
        
        <asp:Panel ID="PnlView" runat="server" Visible="false">
        <div style="width:60%; margin-left:20%; margin-right:20%; margin-top:10px; text-align:center">
          <asp:GridView ID="GrdVoucher" runat="server" CssClass="gridview" Width="100%" RowStyle-CssClass="gridviewitem"
                        PagerStyle-CssClass="pgr" AutoGenerateColumns="false" AlternatingRowStyle-CssClass="gridview_alternate"
                        onselectedindexchanged="GrdVoucher_SelectedIndexChanged" DataKeyNames="TYPEID" 
                         EmptyDataRowStyle-CssClass="emptyrow" EmptyDataText="No Record Exist!" >
            <Columns>
            <asp:TemplateField HeaderText="S.No" ItemStyle-HorizontalAlign="Center">
               <ItemTemplate>  <%#Container.DataItemIndex+1%></ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField HeaderText="Voucher Name" DataField="Transactionname" ItemStyle-HorizontalAlign="Left" />
             <asp:BoundField HeaderText="Effective Date" DataField="Effectivedate" DataFormatString="{0:dd-MMM-yyyy}" />
              <asp:CommandField HeaderText="Edit" SelectText="<img src='../../Menu/images/Edit_user.png' alt='Edit'>"
              ShowSelectButton="true" />
            </Columns>            
          </asp:GridView>
        </div>
        </asp:Panel>
    
    </form>
</body>
</html>
